package org.example.test;

import cn.hutool.json.JSONUtil;
import com.bj58.zhuanzhuan.zzarch.common.util.JsonUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.protobuf.InvalidProtocolBufferException;
import org.example.extren.HotSeriesListConfig;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author liyishan
 * @date 2025/3/2
 * @description
 */

public class JsonExample {
    public static void main(String[] args) throws InvalidProtocolBufferException, JsonProcessingException {
        HotSeriesListConfig hotSeriesListConfig = new HotSeriesListConfig();
        HotSeriesListConfig.HotSeriesList hotSeriesList = new HotSeriesListConfig.HotSeriesList();
        hotSeriesList.setSeriesId(1);
        hotSeriesList.setSeriesPic("https://www.baidu.com");
        Map<String, List<HotSeriesListConfig.HotSeriesList>> hotSeriesListMap = new HashMap<>();
        hotSeriesListMap.put("1", Arrays.asList(hotSeriesList));
        hotSeriesListConfig.setHotSeriesListMap(hotSeriesListMap);


        System.out.println(JsonUtil.object2String(hotSeriesListConfig));
        //相对于上一步catch了异常
        System.out.println(JsonUtil.silentObject2String(hotSeriesListConfig));

        //脱敏效果
        System.out.println(JsonUtil.object2DesensitizeString(hotSeriesListConfig));
        //相对于上一步catch了异常
        System.out.println(JsonUtil.silentObject2DesensitizeString(hotSeriesListConfig));


        //格式美化
        System.out.println(JsonUtil.object2StringPretty(hotSeriesListConfig));
        //相对于上一步catch了异常
        System.out.println(JsonUtil.silentObject2StringPretty(hotSeriesListConfig));



        System.out.println(JSONUtil.toJsonStr(hotSeriesListConfig));

    }
}
